import 'package:FineArt/constants.dart';
import 'package:FineArt/utils/size_config.dart';
import 'package:badges/badges.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:FineArt/router/router.dart';

/// 通知列表
class NoticeItemView extends StatelessWidget {
  //
  final String content;
  final bool isRead;

  //
  final String date;

  //文章标题
  final String title;

  NoticeItemView(
      {Key key,
      this.content = '',
      this.date = '',
      this.title = '这里是标题',
      this.isRead = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
        onTap: () {},
        child: Container(
          padding: EdgeInsets.symmetric(vertical: 5, horizontal: 10),
          color: Colors.white,
          child: Column(
            children: [
              SizedBox(
                height: 15,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  Image.asset(
                    "assets/images/icon_notice_item.png",
                    width: getPortraitSWidth(16),
                    height: getPortraitSHeight(16),
                  ),
                  SizedBox(
                    width: 5,
                  ),
                  Badge(
                    position: BadgePosition.topStart(
                        top: 0, start: getPortraitSWidth(60)),
                    child: Text(
                      title,
                      style: TextStyle(fontSize: setSp(15), color: text_black),
                    ),
                    showBadge: !isRead,
                  ),
                  Expanded(child: Text("")),
                  Text(
                    date,
                    style:
                        TextStyle(fontSize: setSp(12), color: text_date_gray),
                  ),
                ],
              ),
              SizedBox(
                height: 5,
              ),
              InkWell(
                child: Row(
                  children: [
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      child: Text(
                        content,
                        style: TextStyle(
                            fontSize: setSp(12), color: text_date_gray),
                        overflow: TextOverflow.ellipsis,
                        maxLines: 10,
                      ),
                    )
                  ],
                ),
                onTap: () {},
              )
            ],
          ),
        ));
  }
}

class ArticleInfo {
  //文章地址
  final String articleUrl;

  //图片地址
  final String imageUrl;

  //文章标题
  final String title;

  //文章作者
  final String author;

  //作者描述
  final String description;

  //文章摘要
  final String summary;

  const ArticleInfo(this.articleUrl, this.imageUrl, this.title, this.summary,
      {this.author = 'xuexiang', this.description = 'Android架构师'});
}
